class Solution:
    def peopleAwareOfSecret(self, n: int, delay: int, forget: int) -> int:
        # dp[i][0]产生的人 dp[i][1]遗忘的人
        dp = [[0 for _ in range(2)] for _ in range(n + 1)]
        dp[1][0] = 1
        sums = 0
        for i in range(1, n + 1):
            if i > forget:
                dp[i][1] = dp[i - forget][0]
            for j in range(i - delay, 0, -1):
                dp[i][0] += dp[j][0]
            for j in range(i - 1, 0, -1):
                dp[i][0] -= dp[j][1]
        ans = 0
        for i in range(1, n + 1):
            ans += (dp[i][0] - dp[i][1])

        return ans


if __name__ == '__main__':
    s = Solution()
    r = s.peopleAwareOfSecret(n=6, delay=2, forget=4)
    print(r)
